home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
Z4CSBLD.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-17
|
5KB
|
189 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: z4csbld.c
// Title: 9-Digit ZIP Code Directory -- on CD-ROM
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
// This module contains the program entry point for
//
// The code in this module may be written in C++ or C.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
//
//----------------------------------------------------------------------------
#include <z4.h>
//----------------------------------------------------------------------------
// Stack size
//----------------------------------------------------------------------------
#if COMPILER_BORLAND && (OS_DOS || OS_WINDOWS)
unsigned _stklen = 0x4000;
#endif
//----------------------------------------------------------------------------
// Globals
//----------------------------------------------------------------------------
//
// A useless string which is simply embedded in the executable.
//
PSZ __pszCredits__ = "Written by John M Weeder, 1993";
//
// This should contain a program description which will be displayed as
// part of the program's help text.
//
static PCSZ pcszDescription =
"This program builds the city/state primary data files";
//
// Program command line options
//
static DATACFG dcfg;
static BOOL fStrip = FALSE;
static BOOL fSort = FALSE;
static BOOL fCompress = FALSE;
static BOOL fIndex = FALSE;
static BOOL fRecNo = FALSE;
static BOOL fCheck = FALSE;
static CHAR szConfig[MAX_PATH] = "z4cs";
static BS_CMDOPT acmdopt[] =
{
{ "CHECK", (PVOID)&fCheck, CMDOPT_TRUE, "Validate CRC codes."},
{ "COMPRESS", (PVOID)&fCompress, CMDOPT_TRUE, "Compress data file."},
{ "INDEX", (PVOID)&fIndex, CMDOPT_TRUE, "Index data file."},
{ "RECNO", (PVOID)&fRecNo, CMDOPT_TRUE, "Process record count file."},
{ "STRIP", (PVOID)&fStrip, CMDOPT_TRUE, "Strip fixed length data file."},
{ "SORT", (PVOID)&fSort, CMDOPT_TRUE, "Sort stripped data file."},
{ "config", (PVOID)szConfig, CMDOPT_FILESPEC(80), "Configuration file name."},
BS_CMDOPT_NULL,
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
VOID FN_E Z4Strip(PDATACFG pcfg, PRECID precid, PSZ _FAR_ *apsz, PBYTE pb)
{
static SIZET cCity;
static SIZET cCityAbbrev;
static SIZET cLLName;
NOTUSED(precid);
NOTUSED(pb);
if (apsz == NULL)
{
cCity = DataField(pcfg, "city_name");
cCityAbbrev = DataField(pcfg, "city_abbrev");
cLLName = DataField(pcfg, "last_line_name");
return ;
}
Z4Clean(apsz[cCity]);
Z4Clean(apsz[cCityAbbrev]);
Z4Clean(apsz[cLLName]);
return ;
}
//----------------------------------------------------------------------------
// Description: main() - Program entry point
// Parameters: Standard C parameters
// Returns: DOS return code.
//----------------------------------------------------------------------------
int main(int argc, char **argv)
{
static BS_CFG cfg = CFG_DFT;
int retval = 99;
//
// Initialize base library
//
BaseLibraryInitialize(argc, argv, &cfg);
BaseTitle("$Revision: 93.1 $", __DATE__, __TIME__, "ZIP+4 City/State File Build");
if (!BaseTitleHelp(acmdopt, pcszDescription,0))
return 99;
DioSetDataPath(getenv("DATA"));
if (!DataConfigRead(szConfig, &dcfg))
{
Output("Failed reading configuration file.\n");
goto ERROR_EXIT;
}
if (fStrip)
if (!DataStrip(&dcfg, Z4Strip))
{
Output("Failed stripping fixed length records.\n");
goto ERROR_EXIT;
}
if (fSort)
if (!DataSort(&dcfg))
{
Output("Failed sorting delimited data file.\n");
goto ERROR_EXIT;
}
if (fCompress)
{
if (!DataCompress(&dcfg, Z4CSCompress, DAC_XREF|DAC_RECNO))
{
Output("Failed compressing delimited data file.\n");
goto ERROR_EXIT;
}
}
if (fRecNo)
if (!DataRecNo(&dcfg))
{
Output("Failed generating record number index.\n");
return 99;
}
if (fIndex)
if (!DataIndex(&dcfg, Z4CSIndex))
{
Output("Failed indexing CS data file.\n");
return 99;
}
if (fCheck)
if (!DioCheck(dcfg.szData))
{
Output("Failed verifying data file.\n");
return 99;
}
retval = 0;
ERROR_EXIT:
DioCloseAll();
return retval;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------